package com.j283_5.wisdom_park.controller.confcenter_management.user;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.j283_5.wisdom_park.common.result.ResultData;
import com.j283_5.wisdom_park.pojo.Roleinfo;
import com.j283_5.wisdom_park.pojo.User;
import com.j283_5.wisdom_park.service.UserService;
import com.j283_5.wisdom_park.vo.confcenter_management.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/user")
@Api(value = "用户管理",tags = "用户管理",produces = "罗移筵")
public class UserController {
    @Resource
    private UserService userService;
    /**
     * 查询所有用户信息
     * @param page
     * @param usName
     * @return
     */
    @RequestMapping(value = "/getuserInfo",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有用户信息",notes = "查询所有用户信息（分页）",produces = "罗移筵",response = ResultData.class)
    public ResultData getuserInfo(@Param("page") Page<User> page, String usName){
        return userService.getuserInfo(page,usName);
    }

    /**
     * 添加用户
     * @param userVo
     * @return
     */
    @RequestMapping(value = "/addUserInfo",method = RequestMethod.POST)
    @ApiOperation(value = "添加用户",notes = "添加用户",produces = "罗移筵",response = ResultData.class)
    public ResultData addUserInfo(@RequestBody UserVo userVo){
        return userService.addUserInfo(userVo);
    }

    /**
     * 删除用户
     * @param usIdlist
     * @return
     */
    @RequestMapping(value = "/deleteUser",method = RequestMethod.POST)
    @ApiOperation(value = "删除用户",notes = "删除用户",produces = "罗移筵",response = ResultData.class)
    public ResultData deleteUser(@RequestBody ArrayList<Integer> usIdlist){
        return userService.deleteUser(usIdlist);
    }

    /**
     * 修改用户信息
     * @param user
     * @return
     */
    @RequestMapping(value = "/updateUser",method = RequestMethod.POST)
    @ApiOperation(value = "修改用户",notes = "修改用户",produces = "罗移筵",response = ResultData.class)
    public ResultData updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }
}
